<?php
if (!defined('ROOT_PATH')) die('No direct access.');
function view_toko($id){
	view_header_top();
	$user = getUser($id);
	$pembeli = (isset($_SESSION['logged']['id'])) ? $_SESSION['logged']['id'] : "";
	//----------------------------------------------------------------
	$title = "Realita - ".$user['nama-toko'];
	$content = "Realita ".$user['nama-toko'];
	$url = TOKO_URL."a/".$user['idFB'];
	$image = IMAGE_URL."300x240.gif";	//profpic / tokonya
	$desc = "Deskripsi toko : ".$user['deskripsi-toko'];
	$auth = "RealiTA";
	$qwords = "toko, marketplace, umkm, ".$user['nama'].", ".$user['nama-toko'];
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
?>
<ul class="breadcrumbs">
	  <li><a href="<?php echo HOME_URL."" ?>">Beranda</a></li>
	  <li><a href="<?php echo MARKETPLACE_URL."" ?>">Marketplace</a></li>
	  <li class="current"><a href="<?php echo TOKO_URL."a/".$user['idFB']."/".$user['slug_nama-toko'] ?>"><?php echo $user['nama-toko'] ?></a></li>
	</ul>
    <h2><?php echo $user['nama-toko'] ?></h2>
    <div class="large-4 small-12 columns">
	  <div class="hide-for-small panel">
		<img src="<?php echo IMAGE_URL."toko/$user['idFB']/logo.jpg" ?>" />
		<h6 class="subheader">"<?php echo $user['deskripsi-toko'] ?>"</h6>
		<h6 class="subheader"><?php echo $user['alamat-toko'] ?></h6>
	  </div>
	  <div class="fb-like-box" data-href="http://www.facebook.com/idebeda.piranti.cerdas" data-width="290" data-height="520" data-colorscheme="light" data-show-faces="true" data-header="true" data-stream="true" data-show-border="true"></div><br />
		<ul class="side-nav">
		  <li><a href="#" onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;"><img src="<?php echo IMAGE_URL ?>fb-share-button.gif" /></a></li>
		  <li><div class="fb-like" data-href="http://cafe.idebeda.com/ronda-sebagai-programmer/" data-width="290" data-height="300" data-colorscheme="light" data-layout="button_count" data-action="like" data-show-faces="true" data-send="false"></div></li>
		  <hr />
		  <?php
		  if (cekSdhBeli($pembeli,$user['idFB'])){
			  echo "<li>Nilai rating</li>";
		  }
		  ?>
		  <li>Level Penjual</li>
		  <li><a href="<?php echo PROFIL_URL."a/".$user['idFB']; ?>"><?php echo $user['nama'] ?></a></li>
		  <!--li>Twit Share</li-->
		</ul>
    </div>
    <!-- End Side Bar -->

    <!-- Thumbnails -->
    <form action="" method="GET">
		<div class="small-6 columns">
			<input name="tags" type="text" placeholder="Kata kunci nama barang, tag">
		</div>
        <div class="small-2 columns">
			<input class="small button" name="c" type="submit" value="Cari" />
        </div>
    </form>
    
        <div class="large-8 columns">
			<?php
			if (isset($_SESSION['status-tambah'])) {
				echo "<div class='alert-box success'>".$_SESSION['status-tambah']."<a href='#' class='close'>&times;</a></div>";
				unset($_SESSION['status-tambah']);
			}
			?>
          <div class="row">
            <?php
				$tags = (isset($_GET['tags'])) ? $_GET['tags'] : '';
				$tag = explodeTrim(" ",$tags);
				$query = getBarangToko($user['idPengguna'],$tag);
				$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
				if (strpos($url,'?')>0) $url = substr($url,0,strpos($url,'?'));
				$url.="?";
				$result = paginasi($query,$url,1);
				$barangs = $result['sql'];
				foreach ($barangs as $barang) {
			?>
            <div class="large-4 small-6 columns">
              <a href="<? echo BARANG_URL."a/".$barang['idBarang']."/".$barang['slug-nama'] ?>"><img src="<? echo IMAGE_URL ?>1000x1000.gif"></a>
              <div class="panel">
                <a href="<? echo BARANG_URL."a/".$barang['idBarang']."/".$barang['slug-nama'] ?>"><h5><?php echo $barang['nama'] ?> <a href="<?php echo KERANJANG_URL."beli?id=".$barang['idBarang']."&qty=1&beli=Beli" ?>"><img src="<?php echo IMAGE_URL ?>cart-add.png" /></a></h5></a>
                <h6 class="subheader"><?php echo int_to_rp($barang['harga']) ?></h6>
              </div>
            </div>
            <?php } 
				echo $result['page'];
					/*if (isset($_SESSION['logged'])){
						echo "<br /><a href=\"".BLOG_URL."buat/$id/toko\">[Buat Review]</a>";
					}
					$articles = getArtikelnya($user['idPengguna']);
					foreach ($articles as $article){
						 echo "<a href=\"".BLOG_URL."a/".$article['idArtikel']."/".$article['slug-judul']."\">".$article['judul']."</a><br />";
					}*/
				$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
				if (strpos($url,'?')>0) $url = substr($url,0,strpos($url,'?'));
				?>
				</div>
			<!--/div-->
			<hr />
            <div class="row">
				<div class="large-8 small-8 columns">
				  Teman yang sudah beli di toko (jumlah, facepiles)
				</div>
			</div>
			<hr />
            <div class="row">
				<div class="large-8 small-8 columns">
				  <div class="fb-comments" data-href="<?php echo $url?>" data-colorscheme="light" data-numposts="3" data-width="The pixel width of the plugin"></div>
				</div>
			</div>
          </div>
    <!-- End Thumbnails -->    
  </div>
<?php
	view_footer();
}
?>
